home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Pascal / Snippets / PNL Libraries / NSSpriteWorld8BitBlitters.c < prev    next >
Text File  |  1997-04-23  |  16KB  |  700 lines

  1. ///--------------------------------------------------------------------------------------
  2. //    BlitPixie8Bit.c
  3. //
  4. //    Ideas and code snippets contributed by:
  5. //        Ben Sharpe, Brigham Stevens, Sean Callahan, Joe Britt and Tim Collins
  6. //
  7. //    Portions are copyright: © 1991-94 Tony Myles
  8. //
  9. //    Description: Implementation of BlitPixie8Bit - a fast 8-bit blitter
  10. ///--------------------------------------------------------------------------------------
  11.  
  12.  
  13. #ifndef __TOOLUTILS__
  14. #include <ToolUtils.h>
  15. #endif
  16.  
  17. #ifndef __OSUTILS__
  18. #include <OSUtils.h>
  19. #endif
  20.  
  21. #ifndef __QUICKDRAW__
  22. #include <Quickdraw.h>
  23. #endif
  24.  
  25. #ifndef __QDOFFSCREEN__
  26. #include <QDOffscreen.h>
  27. #endif
  28.  
  29. #ifndef __NSSPRITEWORLD8BITBLITTER__
  30. #include "NSSpriteWorld8BitBlitters.h"
  31. #endif
  32.  
  33.  
  34. #if GENERATINGPOWERPC
  35. ///--------------------------------------------------------------------------------------
  36. //        BlitPixie8Bit
  37. ///--------------------------------------------------------------------------------------
  38. void BlitPixie8Bit(
  39.     PixelChunkPtr srcPixelP,
  40.     PixelChunkPtr dstPixelP,
  41.     register unsigned long rowsToCopy,
  42.     register unsigned long numBytesPerRow,
  43.     register unsigned long srcOffset,
  44.     register unsigned long dstOffset)
  45. {
  46.     register long index;
  47.     register PixelChunkPtr startSrcPixelP;
  48.     register PixelChunkPtr startDstPixelP;
  49.     
  50.         
  51.     startSrcPixelP = srcPixelP;
  52.     startDstPixelP = dstPixelP;
  53.  
  54.     while (rowsToCopy--)
  55.     {
  56.         register fourblits = (numBytesPerRow >> 2);
  57.         
  58.         srcPixelP = startSrcPixelP;
  59.         dstPixelP = startDstPixelP;
  60.         
  61.         for (index = 0; index < fourblits; index++)
  62.         {
  63.             register unsigned long temp1;
  64.             
  65.             temp1 = srcPixelP[index];
  66.             dstPixelP[index] = temp1;
  67.         }
  68.         srcPixelP += fourblits;
  69.         dstPixelP += fourblits;
  70.         if (numBytesPerRow & 0x2)
  71.             *((unsigned short *) dstPixelP)++ = *((unsigned short *) srcPixelP)++;
  72.         if (numBytesPerRow & 0x1)
  73.             *((unsigned char *)dstPixelP)++ = *((unsigned char *)srcPixelP)++;
  74.  
  75.             // bump to next row    
  76.         (char *)startSrcPixelP += srcOffset;
  77.         (char *)startDstPixelP += dstOffset;
  78.     }
  79. }
  80.  
  81.  
  82. ///--------------------------------------------------------------------------------------
  83. //        BlitPixieMask8Bit
  84. ///--------------------------------------------------------------------------------------
  85.  
  86. void BlitPixieMask8Bit(
  87.     register PixelPtr srcPixelP,
  88.     register PixelPtr dstPixelP,
  89.     register PixelPtr maskPixelP,
  90.     register unsigned long rowsToCopy,
  91.     register unsigned long numBytesPerRow,
  92.     register unsigned long srcOffset,
  93.     register unsigned long dstOffset)
  94. {
  95.     register long index;
  96.     register PixelPtr startSrcPixelP;
  97.     register PixelPtr startDstPixelP;
  98.     register PixelPtr startMaskPixelP;
  99.     
  100.     startSrcPixelP = srcPixelP;
  101.     startDstPixelP = dstPixelP;
  102.     startMaskPixelP = maskPixelP;
  103.     
  104.     while (rowsToCopy--)    
  105.     {
  106.         register fourblits = (numBytesPerRow >> 2);
  107.         
  108.         srcPixelP = startSrcPixelP;
  109.         dstPixelP = startDstPixelP;
  110.         maskPixelP = startMaskPixelP;
  111.         
  112.         for (index = 0; index < fourblits; index++)
  113.         {
  114.             register unsigned long temp1;
  115.             
  116.             temp1 = dstPixelP[index] & maskPixelP[index] | srcPixelP[index];
  117.             dstPixelP[index] = temp1;
  118.         }
  119.         srcPixelP += fourblits;
  120.         dstPixelP += fourblits;
  121.         maskPixelP += fourblits;
  122.         if (numBytesPerRow & 0x2)
  123.         {
  124.             register unsigned short temp1;
  125.             
  126.             temp1 = (*((unsigned short *) dstPixelP)) & (*((unsigned short *) maskPixelP)++) |
  127.             *((unsigned short *) srcPixelP)++;
  128.             
  129.             (*((unsigned short *) dstPixelP)++) = temp1;
  130.         }
  131.         if (numBytesPerRow & 0x1)
  132.         {
  133.             register unsigned char temp1;
  134.             
  135.             temp1 = (*((unsigned char *) dstPixelP)) & (*((unsigned char *) maskPixelP)++) |
  136.             *((unsigned char *) srcPixelP)++;
  137.             
  138.             (*((unsigned char *) dstPixelP)++) = temp1;
  139.         }
  140.  
  141.             // bump to next row
  142.         startSrcPixelP = (PixelPtr)(((char*)startSrcPixelP) + srcOffset);
  143.         startDstPixelP = (PixelPtr)(((char*)startDstPixelP) + dstOffset);
  144.         startMaskPixelP = (PixelPtr)(((char*)startMaskPixelP) + srcOffset);
  145.     }
  146. }
  147.  
  148.  
  149. ///--------------------------------------------------------------------------------------
  150. //        BlitPixiePartialMask8Bit
  151. ///--------------------------------------------------------------------------------------
  152.  
  153. void BlitPixiePartialMask8Bit(
  154.     register PixelPtr srcPixelP,
  155.     register PixelPtr dstPixelP,
  156.     register PixelPtr maskPixelP,
  157.     register unsigned long rowsToCopy,
  158.     register unsigned long numBytesPerRow,
  159.     register unsigned long srcOffset,
  160.     register unsigned long dstOffset)
  161. {
  162.     register long index;
  163.     register PixelPtr startSrcPixelP;
  164.     register PixelPtr startDstPixelP;
  165.     register PixelPtr startMaskPixelP;
  166.     
  167.     startSrcPixelP = srcPixelP;
  168.     startDstPixelP = dstPixelP;
  169.     startMaskPixelP = maskPixelP;
  170.     
  171.     while (rowsToCopy--)    
  172.     {
  173.         register fourblits = (numBytesPerRow >> 2);
  174.         
  175.         srcPixelP = startSrcPixelP;
  176.         dstPixelP = startDstPixelP;
  177.         maskPixelP = startMaskPixelP;
  178.         
  179.         for (index = 0; index < fourblits; index++)
  180.         {
  181.             register unsigned long temp1;
  182.             
  183.             temp1 = dstPixelP[index] & maskPixelP[index] | 
  184.                 ( (~maskPixelP[index])&srcPixelP[index]);
  185.             dstPixelP[index] = temp1;
  186.         }
  187.         srcPixelP += fourblits;
  188.         dstPixelP += fourblits;
  189.         maskPixelP += fourblits;
  190.         if (numBytesPerRow & 0x2)
  191.         {
  192.             register unsigned short temp1;
  193.             
  194.             temp1 = (*((unsigned short *) dstPixelP)) & (*((unsigned short *) maskPixelP)) |
  195.             (~(*((unsigned short *) maskPixelP)++) &
  196.             *((unsigned short *) srcPixelP)++);
  197.                 
  198.             (*((unsigned short *) dstPixelP)++) = temp1;
  199.         }
  200.         if (numBytesPerRow & 0x1)
  201.         {
  202.             register unsigned char temp1;
  203.             
  204.             temp1 = (*((unsigned char *) dstPixelP)) & (*((unsigned char *) maskPixelP)) |
  205.             (~(*((unsigned char *) maskPixelP)++) &
  206.             *((unsigned char *) srcPixelP)++);
  207.                 
  208.             (*((unsigned char *) dstPixelP)++) = temp1;
  209.         }
  210.         
  211.             // bump to next row
  212.         startSrcPixelP = (PixelPtr)(((char*)startSrcPixelP) + srcOffset);
  213.         startDstPixelP = (PixelPtr)(((char*)startDstPixelP) + dstOffset);
  214.         startMaskPixelP = (PixelPtr)(((char*)startMaskPixelP) + srcOffset);
  215.     }
  216. }
  217.  
  218.  
  219. #else /* SW_USE_C */
  220.  
  221. ///--------------------------------------------------------------------------------------
  222. //        BlitPixie8Bit
  223. ///--------------------------------------------------------------------------------------
  224.  
  225. asm void BlitPixie8Bit(
  226.     register PixelPtr srcPixelP,
  227.     register PixelPtr dstPixelP,
  228.     register unsigned long rowsToCopy,
  229.     register unsigned long numBytesPerRow,
  230.     register unsigned long srcRowStride,
  231.     register unsigned long dstRowStride)
  232. {
  233.     register unsigned long loopsPerRow;
  234.  
  235.         machine 68020
  236.  
  237. #if __MWERKS__
  238.         fralloc +
  239. #endif
  240.  
  241.         sub.l    numBytesPerRow, srcRowStride
  242.         sub.l    numBytesPerRow, dstRowStride
  243.         
  244.             // longWordsPerRow = numBytesPerRow >> 2;
  245.         move.l    numBytesPerRow, d0
  246.         lsr.l    #2, d0
  247.  
  248.             // numBytesPerRow -= longWordsPerRow << 2;
  249.         move.l    d0, d1
  250.         lsl.l    #2, d1
  251.         sub.l    d1, numBytesPerRow
  252.  
  253.             // loopsPerRow = longWordsPerRow >> 4;
  254.         move.l    d0, loopsPerRow
  255.         lsr.l    #4, loopsPerRow
  256.  
  257.         moveq    #0xF, d1
  258.         and.l    d1, d0
  259.         add.l    d0, d0            // multiply longWordsPerRow by 2 (size of move.l (srcPixelP)+,(dstPixelP)+)
  260.         lea     @loopEnd, a0    // get address of the end of the loop
  261.         suba.l    d0, a0            // calculate where to jmp in the loop
  262.  
  263.     @forEachRow:
  264.         move.l    loopsPerRow, d0
  265.         jmp        (a0)
  266.     @loopBase:
  267.         move.l    (srcPixelP)+, (dstPixelP)+    // 16
  268.         move.l    (srcPixelP)+, (dstPixelP)+    // 15
  269.         move.l    (srcPixelP)+, (dstPixelP)+    // 14
  270.         move.l    (srcPixelP)+, (dstPixelP)+    // 13
  271.         move.l    (srcPixelP)+, (dstPixelP)+    // 12
  272.         move.l    (srcPixelP)+, (dstPixelP)+    // 11 
  273.         move.l    (srcPixelP)+, (dstPixelP)+    // 10
  274.         move.l    (srcPixelP)+, (dstPixelP)+    //  9
  275.         move.l    (srcPixelP)+, (dstPixelP)+    //  8
  276.         move.l    (srcPixelP)+, (dstPixelP)+    //  7
  277.         move.l    (srcPixelP)+, (dstPixelP)+    //  6
  278.         move.l    (srcPixelP)+, (dstPixelP)+    //  5
  279.         move.l    (srcPixelP)+, (dstPixelP)+    //  4
  280.         move.l    (srcPixelP)+, (dstPixelP)+    //  3
  281.         move.l    (srcPixelP)+, (dstPixelP)+    //  2
  282.         move.l    (srcPixelP)+, (dstPixelP)+    //  1
  283.     @loopEnd:
  284.         subq.l    #1,d0
  285.         bpl        @loopBase
  286.  
  287.         // now do any leftover bits
  288.         move.l    numBytesPerRow, d0
  289.         beq        @nextRow
  290.         subq.l    #2, d0
  291.         bmi        @moveByte
  292.         move.w    (srcPixelP)+, (dstPixelP)+
  293.         tst        d0
  294.         beq        @nextRow
  295.     @moveByte:    
  296.         move.b    (srcPixelP)+, (dstPixelP)+
  297.  
  298.     @nextRow:
  299.         adda.l    srcRowStride, srcPixelP
  300.         adda.l    dstRowStride, dstPixelP
  301.         subq.l    #1, rowsToCopy
  302.         bne        @forEachRow
  303.  
  304. #if __MWERKS__
  305.         frfree
  306. #endif
  307.  
  308.         rts
  309. }
  310.  
  311.  
  312.  
  313. ///--------------------------------------------------------------------------------------
  314. //        BlitPixieMask8Bit
  315. ///--------------------------------------------------------------------------------------
  316.  
  317. asm void BlitPixieMask8Bit(
  318.     register PixelPtr srcPixelP,
  319.     register PixelPtr dstPixelP,
  320.     register PixelPtr maskPixelP,
  321.     register unsigned long rowsToCopy,
  322.     register unsigned long numBytesPerRow,
  323.     register unsigned long srcRowStride,
  324.     register unsigned long dstRowStride)
  325. {
  326.     register unsigned long loopsPerRow;
  327.  
  328.         machine 68020
  329.  
  330. #if __MWERKS__
  331.         fralloc +
  332. #endif
  333.  
  334.         sub.l    numBytesPerRow, srcRowStride
  335.         sub.l    numBytesPerRow, dstRowStride
  336.         
  337.             // longWordsPerRow = numBytesPerRow >> 2;
  338.         move.l    numBytesPerRow, d0
  339.         lsr.l    #2, d0
  340.  
  341.             // numBytesPerRow -= longWordsPerRow << 2;
  342.         move.l    d0, d1
  343.         lsl.l    #2, d1
  344.         sub.l    d1, numBytesPerRow
  345.  
  346.             // loopsPerRow = longWordsPerRow >> 4;
  347.         move.l    d0, loopsPerRow
  348.         lsr.l    #4, loopsPerRow
  349.  
  350.             
  351.         moveq    #0xF, d1
  352.         and.l    d1, d0
  353.         lsl.l    #3, d0                    // longWordsPerRow *= 8;
  354.         lea     @loopEnd, a0            // get address of the end of the loop
  355.         sub.l    d0, a0                    // calculate where to jmp in the loop
  356.  
  357.     @forEachRow:
  358.         move.l    loopsPerRow, d2
  359.         jmp        (a0)
  360.     @loopBase:
  361.             // 16
  362.         move.l    (dstPixelP), d0
  363.         and.l    (maskPixelP)+, d0
  364.         or.l    (srcPixelP)+, d0
  365.         move.l    d0, (dstPixelP)+
  366.             // 15
  367.         move.l    (dstPixelP), d0
  368.         and.l    (maskPixelP)+, d0
  369.         or.l    (srcPixelP)+, d0
  370.         move.l    d0, (dstPixelP)+
  371.             // 14
  372.         move.l    (dstPixelP), d0
  373.         and.l    (maskPixelP)+, d0
  374.         or.l    (srcPixelP)+, d0
  375.         move.l    d0, (dstPixelP)+
  376.           // 13
  377.         move.l    (dstPixelP), d0
  378.         and.l    (maskPixelP)+, d0
  379.         or.l    (srcPixelP)+, d0
  380.         move.l    d0, (dstPixelP)+
  381.           // 12
  382.         move.l    (dstPixelP), d0
  383.         and.l    (maskPixelP)+, d0
  384.         or.l    (srcPixelP)+, d0
  385.         move.l    d0, (dstPixelP)+
  386.           // 11
  387.         move.l    (dstPixelP), d0
  388.         and.l    (maskPixelP)+, d0
  389.         or.l    (srcPixelP)+, d0
  390.         move.l    d0, (dstPixelP)+
  391.           // 10
  392.         move.l    (dstPixelP), d0
  393.         and.l    (maskPixelP)+, d0
  394.         or.l    (srcPixelP)+, d0
  395.         move.l    d0, (dstPixelP)+
  396.           //  9
  397.         move.l    (dstPixelP), d0
  398.         and.l    (maskPixelP)+, d0
  399.         or.l    (srcPixelP)+, d0
  400.         move.l    d0, (dstPixelP)+
  401.           //  8
  402.         move.l    (dstPixelP), d0
  403.         and.l    (maskPixelP)+, d0
  404.         or.l    (srcPixelP)+, d0
  405.         move.l    d0, (dstPixelP)+
  406.           //  7
  407.         move.l    (dstPixelP), d0
  408.         and.l    (maskPixelP)+, d0
  409.         or.l    (srcPixelP)+, d0
  410.         move.l    d0, (dstPixelP)+
  411.             //  6
  412.         move.l    (dstPixelP), d0
  413.         and.l    (maskPixelP)+, d0
  414.         or.l    (srcPixelP)+, d0
  415.         move.l    d0, (dstPixelP)+
  416.           //  5
  417.         move.l    (dstPixelP), d0
  418.         and.l    (maskPixelP)+, d0
  419.         or.l    (srcPixelP)+, d0
  420.         move.l    d0, (dstPixelP)+
  421.           //  4
  422.         move.l    (dstPixelP), d0
  423.         and.l    (maskPixelP)+, d0
  424.         or.l    (srcPixelP)+, d0
  425.         move.l    d0, (dstPixelP)+
  426.           //  3
  427.         move.l    (dstPixelP), d0
  428.         and.l    (maskPixelP)+, d0
  429.         or.l    (srcPixelP)+, d0
  430.         move.l    d0, (dstPixelP)+
  431.         //  2
  432.         move.l    (dstPixelP), d0
  433.         and.l    (maskPixelP)+, d0
  434.         or.l    (srcPixelP)+, d0
  435.         move.l    d0, (dstPixelP)+
  436.           //  1
  437.         move.l    (dstPixelP), d0
  438.         and.l    (maskPixelP)+, d0
  439.         or.l    (srcPixelP)+, d0
  440.         move.l    d0, (dstPixelP)+
  441.     @loopEnd:
  442.         subq.l    #1, d2
  443.         bpl        @loopBase
  444.  
  445.         // now do any leftover bits
  446.         move.l    numBytesPerRow, d2
  447.         beq        @nextRow
  448.         subq.l    #2, d2
  449.         bmi        @moveByte
  450.         move.w    (dstPixelP), d0
  451.         and.w    (maskPixelP)+, d0
  452.         or.w    (srcPixelP)+, d0
  453.         move.w    d0, (dstPixelP)+
  454.         tst        d2
  455.         beq        @nextRow
  456.     @moveByte:    
  457.         move.b    (dstPixelP), d0
  458.         and.b    (maskPixelP)+, d0
  459.         or.b    (srcPixelP)+, d0
  460.         move.b    d0, (dstPixelP)+
  461.  
  462.     @nextRow:
  463.         adda.l    srcRowStride, srcPixelP
  464.         adda.l    srcRowStride, maskPixelP
  465.         adda.l    dstRowStride, dstPixelP
  466.         subq.l    #1, rowsToCopy
  467.         bne        @forEachRow
  468.  
  469. #if __MWERKS__
  470.         frfree
  471. #endif
  472.  
  473.         rts
  474. }
  475.  
  476.  
  477.  
  478.  
  479. ///--------------------------------------------------------------------------------------
  480. //        BlitPixiePartialMask8Bit
  481. ///--------------------------------------------------------------------------------------
  482.  
  483. asm void BlitPixiePartialMask8Bit(
  484.     register PixelPtr srcPixelP,
  485.     register PixelPtr dstPixelP,
  486.     register PixelPtr maskPixelP,
  487.     register unsigned long rowsToCopy,
  488.     register unsigned long numBytesPerRow,
  489.     register unsigned long srcRowStride,
  490.     register unsigned long dstRowStride)
  491. {
  492.     register unsigned long loopsPerRow;
  493.  
  494.         machine 68020
  495.  
  496. #if __MWERKS__
  497.         fralloc +
  498. #endif
  499.  
  500.         sub.l    numBytesPerRow, srcRowStride
  501.         sub.l    numBytesPerRow, dstRowStride
  502.  
  503.             // longWordsPerRow = numBytesPerRow >> 2;
  504.         move.l    numBytesPerRow, d0
  505.         lsr.l    #2, d0
  506.  
  507.             // numBytesPerRow -= longWordsPerRow << 2;
  508.         move.l    d0, d1
  509.         lsl.l    #2, d1
  510.         sub.l    d1, numBytesPerRow
  511.  
  512.             // loopsPerRow = longWordsPerRow >> 4;
  513.         move.l    d0, loopsPerRow
  514.         lsr.l    #4, loopsPerRow
  515.  
  516.             
  517.         moveq    #0xF, d1
  518.         and.l    d1, d0
  519.         mulu    #14, d0                    // longWordsPerRow *= 14 (bytes in segment of loop)
  520.         lea     @loopEnd, a0            // get address of the end of the loop
  521.         sub.l    d0, a0                    // calculate where to jmp in the loop
  522.  
  523.     @forEachRow:
  524.         move.l    loopsPerRow, d2
  525.         jmp        (a0)
  526.     @loopBase:
  527.             // 16
  528.         move.l    (dstPixelP), d0
  529.         and.l    (maskPixelP), d0
  530.         move.l    (maskPixelP)+, d1
  531.         not.l    d1
  532.         and.l    (srcPixelP)+, d1
  533.         or.l    d1, d0
  534.         move.l    d0, (dstPixelP)+
  535.             // 15
  536.         move.l    (dstPixelP), d0
  537.         and.l    (maskPixelP), d0
  538.         move.l    (maskPixelP)+, d1
  539.         not.l    d1
  540.         and.l    (srcPixelP)+, d1
  541.         or.l    d1, d0
  542.         move.l    d0, (dstPixelP)+
  543.             // 14
  544.         move.l    (dstPixelP), d0
  545.         and.l    (maskPixelP), d0
  546.         move.l    (maskPixelP)+, d1
  547.         not.l    d1
  548.         and.l    (srcPixelP)+, d1
  549.         or.l    d1, d0
  550.         move.l    d0, (dstPixelP)+
  551.           // 13
  552.         move.l    (dstPixelP), d0
  553.         and.l    (maskPixelP), d0
  554.         move.l    (maskPixelP)+, d1
  555.         not.l    d1
  556.         and.l    (srcPixelP)+, d1
  557.         or.l    d1, d0
  558.         move.l    d0, (dstPixelP)+
  559.           // 12
  560.         move.l    (dstPixelP), d0
  561.         and.l    (maskPixelP), d0
  562.         move.l    (maskPixelP)+, d1
  563.         not.l    d1
  564.         and.l    (srcPixelP)+, d1
  565.         or.l    d1, d0
  566.         move.l    d0, (dstPixelP)+
  567.           // 11
  568.         move.l    (dstPixelP), d0
  569.         and.l    (maskPixelP), d0
  570.         move.l    (maskPixelP)+, d1
  571.         not.l    d1
  572.         and.l    (srcPixelP)+, d1
  573.         or.l    d1, d0
  574.         move.l    d0, (dstPixelP)+
  575.           // 10
  576.         move.l    (dstPixelP), d0
  577.         and.l    (maskPixelP), d0
  578.         move.l    (maskPixelP)+, d1
  579.         not.l    d1
  580.         and.l    (srcPixelP)+, d1
  581.         or.l    d1, d0
  582.         move.l    d0, (dstPixelP)+
  583.           //  9
  584.         move.l    (dstPixelP), d0
  585.         and.l    (maskPixelP), d0
  586.         move.l    (maskPixelP)+, d1
  587.         not.l    d1
  588.         and.l    (srcPixelP)+, d1
  589.         or.l    d1, d0
  590.         move.l    d0, (dstPixelP)+
  591.           //  8
  592.         move.l    (dstPixelP), d0
  593.         and.l    (maskPixelP), d0
  594.         move.l    (maskPixelP)+, d1
  595.         not.l    d1
  596.         and.l    (srcPixelP)+, d1
  597.         or.l    d1, d0
  598.         move.l    d0, (dstPixelP)+
  599.           //  7
  600.         move.l    (dstPixelP), d0
  601.         and.l    (maskPixelP), d0
  602.         move.l    (maskPixelP)+, d1
  603.         not.l    d1
  604.         and.l    (srcPixelP)+, d1
  605.         or.l    d1, d0
  606.         move.l    d0, (dstPixelP)+
  607.             //  6
  608.         move.l    (dstPixelP), d0
  609.         and.l    (maskPixelP), d0
  610.         move.l    (maskPixelP)+, d1
  611.         not.l    d1
  612.         and.l    (srcPixelP)+, d1
  613.         or.l    d1, d0
  614.         move.l    d0, (dstPixelP)+
  615.           //  5
  616.         move.l    (dstPixelP), d0
  617.         and.l    (maskPixelP), d0
  618.         move.l    (maskPixelP)+, d1
  619.         not.l    d1
  620.         and.l    (srcPixelP)+, d1
  621.         or.l    d1, d0
  622.         move.l    d0, (dstPixelP)+
  623.           //  4
  624.         move.l    (dstPixelP), d0
  625.         and.l    (maskPixelP), d0
  626.         move.l    (maskPixelP)+, d1
  627.         not.l    d1
  628.         and.l    (srcPixelP)+, d1
  629.         or.l    d1, d0
  630.         move.l    d0, (dstPixelP)+
  631.           //  3
  632.         move.l    (dstPixelP), d0
  633.         and.l    (maskPixelP), d0
  634.         move.l    (maskPixelP)+, d1
  635.         not.l    d1
  636.         and.l    (srcPixelP)+, d1
  637.         or.l    d1, d0
  638.         move.l    d0, (dstPixelP)+
  639.         //  2
  640.         move.l    (dstPixelP), d0
  641.         and.l    (maskPixelP), d0
  642.         move.l    (maskPixelP)+, d1
  643.         not.l    d1
  644.         and.l    (srcPixelP)+, d1
  645.         or.l    d1, d0
  646.         move.l    d0, (dstPixelP)+
  647.           //  1
  648.         move.l    (dstPixelP), d0
  649.         and.l    (maskPixelP), d0
  650.         move.l    (maskPixelP)+, d1
  651.         not.l    d1
  652.         and.l    (srcPixelP)+, d1
  653.         or.l    d1, d0
  654.         move.l    d0, (dstPixelP)+
  655.     @loopEnd:
  656.         subq.l    #1, d2
  657.         bpl        @loopBase
  658.  
  659.         // now do any leftover bits
  660.         move.l    numBytesPerRow, d2
  661.         beq        @nextRow
  662.         subq.l    #2, d2
  663.         bmi        @moveByte
  664.         move.w    (dstPixelP), d0
  665.         and.w    (maskPixelP), d0
  666.         move.w    (maskPixelP)+, d1
  667.         not.w    d1
  668.         and.w    (srcPixelP)+, d1
  669.         or.w    d1, d0
  670.         move.w    d0, (dstPixelP)+
  671.         tst        d2
  672.         beq        @nextRow
  673.     @moveByte:
  674.         move.b    (dstPixelP), d0
  675.         and.b    (maskPixelP), d0
  676.         move.b    (maskPixelP)+, d1
  677.         not.b    d1
  678.         and.b    (srcPixelP)+, d1
  679.         or.b    d1, d0
  680.         move.b    d0, (dstPixelP)+
  681.  
  682.     @nextRow:
  683.         adda.l    srcRowStride, srcPixelP
  684.         adda.l    srcRowStride, maskPixelP
  685.         adda.l    dstRowStride, dstPixelP
  686.         subq.l    #1, rowsToCopy
  687.         bne        @forEachRow
  688.  
  689. #if __MWERKS__
  690.         frfree
  691. #endif
  692.  
  693.         rts
  694. }
  695.  
  696.  
  697. #endif /* SW_USE_C */
  698.  
  699.  
  700.